﻿namespace Ross.BSCSystem.Controllers
{
    using System.Collections.Generic;
    using System.Web.Http;
    using System.Web.Http.Results;
    using Ross.EntityFramework;
    using Ross.Service;

    [SimpleAuthenticationFilter]
    public class MonthlyPlanController : BaseApiController
    {
        /// <summary>
        /// 返回登录时选择的年份对应员工可查阅的所有部门的所有计划信息.
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public JsonResult<ResultDto<List<Service.Dto.MonthlyPlan>>> GetAll()
        {
            ResultDto<List<Service.Dto.MonthlyPlan>> result = new ResultDto<List<Service.Dto.MonthlyPlan>>();
            using (MonthlyPlanService serv = new MonthlyPlanService(dbContextStr))
            {
                result = serv.Get();
            }
            return this.Json(result);
        }

        [HttpGet]
        public JsonResult<ResultDto<List<Service.Dto.MonthlyPlan>>> GetSubset(string name = "", string month = "", string week = "", string department = "", string Responsible = "")
        {
            ResultDto<List<Service.Dto.MonthlyPlan>> result = new ResultDto<List<Service.Dto.MonthlyPlan>>();
            using (MonthlyPlanService serv = new MonthlyPlanService(dbContextStr))
            {
                result = serv.Get(name, month, week, department, Responsible);
            }
            return this.Json(result);
        }
    }
}
